package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Goods;
import com.atguigu.jxc.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/goodsType")
public class GoodsTypeController {

    @Autowired
    private GoodsService goodsService;

    @PostMapping("/loadGoodsType")
    @ResponseBody
    public List<Map<String,Object>> loadGoodsType(){

        return goodsService.classify();

    }

    @PostMapping("/save")
    @ResponseBody
    public ServiceVO save(String  goodsTypeName,Integer  pId){
        return goodsService.save(goodsTypeName,pId);
    }

    @PostMapping("/delete")
    @ResponseBody
    public ServiceVO delete(Integer goodsTypeId){
        goodsService.delete(goodsTypeId);
        return new ServiceVO(100,"删除成功");
    }

}
